import { service2 } from '@/utils/request'

// /admin/product/{page}/{limit}  获取SPU列表数据  get请求  携带:当前页数(page)，每页数据(limit)  三级id(category3Id)
export const reqSpuList = data => service2.get(`/admin/product/${data.page}/${data.limit}`, { params: { category3Id: data.category3Id } })

// /admin/product/getSpuById/{spuId}  获取spu的基本信息  get请求  携带：spuid(spuId)
export const reSpu = data => service2.get(`/admin/product/getSpuById/${data.spuId}`)

// /admin/product/baseTrademark/getTrademarkList  获取品牌信息  get请求
export const reqTradeMarkList = () => service2.get('/admin/product/baseTrademark/getTrademarkList')

// /admin/product/spuImageList/{spuId}  获取spu图片  get请求   携带：spuid(spuId)
export const reSpuImageList = data => service2.get(`/admin/product/spuImageList/${data.spuId} `)

//  /admin/product/baseSaleAttrList  获取平台的销售属性(3个)  get请求
export const reqBaseSaleAttrList = () => service2.get('/admin/product/baseSaleAttrList')

//  /admin/product/updateSpuInfo   修改spu  post请求
//  /admin/product/saveSpuInfo     添加spu  post请求
export const reqAddOrUpdateSpu = data => {
  if (data.id) {//修改spu
    return service2.post(`/admin/product/updateSpuInfo`, data)
  } else {//添加spu
    return service2.post('/admin/product/saveSpuInfo', data)
  }
}

// /admin/product/deleteSpu/{spuId}  删除spu属性  delete请求
export const reqDelteAttr = (data) => service2.delete(`/admin/product/deleteSpu/${data.spuId}`)


